#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#

import socket
import time

client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect_ex(("127.0.0.1", 2001))

while True:
    sent = input(">>>>: ").strip()
    if not sent: continue
    if sent == "exit": break

    client.sendall(sent.encode("utf-8"))
    data = client.recv(1024)
    gap_time = float(data.decode("utf-8")) - time.time()
    print("客户端与服务端相关时间为: {}".format(gap_time))

client.close()
